package com.nf.recruitment.controller;

import com.nf.recruitment.entity.PostInfo;
import com.nf.recruitment.dto.PostInfoDTO;
import com.nf.recruitment.dto.PostInfoPageDTO;
import com.nf.recruitment.service.PostService;
import com.nf.recruitment.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wangl
 * @date 2021/6/24
 */
@RestController
@RequestMapping("/post")
public class PostController extends BaseController {
    @Autowired
    private PostService service;

    @GetMapping("/list")
    public ResultVO<List<PostInfoDTO>> listPost(int page, int limit) {
        PostInfoPageDTO pageDTO = service.listPost(page, limit);

        return pageResult(pageDTO.getTotal(), pageDTO.getList());
    }

    @PostMapping("/save")
    public ResultVO savePost(@RequestBody PostInfo dto) {
        service.savePost(dto);
        return success();
    }

}
